package com.ddone.controller;

import com.ddone.bean.JpaUser;
import com.ddone.service.JpaUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ddone
 * @date 2024/3/25-14:42
 */
@RestController
@RequestMapping("/jpa/user")
public class JpaUserController {

    @Autowired
    private JpaUserService jpaUserService;

    @GetMapping
    public List<JpaUser> list(){
        return jpaUserService.findUsers();
    }

    @PostMapping
    public String save(JpaUser jpaUser){
        jpaUserService.saveUser(jpaUser);
        return "保存成功";
    }


}
